package com.dy.lock.screen.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.dy.lock.screen.dao.AdvertCollectDao;
import com.dy.lock.screen.pojo.AdvertCollectInfo;
import com.dy.lock.screen.scoket.Head;
import com.dy.lock.screen.service.AdvertCollectService;

@Service("advertCollectService")
public class AdvertCollectServiceImpl implements AdvertCollectService {

	@Resource(name = "advertCollectDao")
	private AdvertCollectDao advertCollectDao;

	@Override
	public int delete(String adId, String userId, Head head) {
		// TODO Auto-generated method stub
		AdvertCollectInfo collect = new AdvertCollectInfo();
		collect.setAdId(adId);
		collect.setUserId(userId);
		return this.advertCollectDao.deleteByAdAndUser(collect);
	}

	@Override
	public int save(AdvertCollectInfo advertCollect, Head head) {
		// TODO Auto-generated method stub
		advertCollect.setId(UUID.randomUUID().toString());
		advertCollect.setCollectTime(new Date());
		return this.advertCollectDao.insert(advertCollect);
	}

	@Override
	public AdvertCollectInfo queryByAdAndUser(String adId, String userId,
			Head head) {
		AdvertCollectInfo collect = new AdvertCollectInfo();
		collect.setAdId(adId);
		collect.setUserId(userId);
		return this.advertCollectDao.queryByAdAndUser(collect);
	}

	@Override
	public List<AdvertCollectInfo> queryPage(Map<String, Object> map, Head head) {
		List<AdvertCollectInfo> list = this.advertCollectDao.queryT(map);
		return list;
	}

}
